import java.util.ArrayList;
import java.util.Random;

/**
 * 
 * @author Devin Wolanick
 * @Version 1.0
 * 
 * Deck is a Collection of Cards
 */

public class Deck implements CardStack{
	
	/**
	 * Variables
	 */
	private ArrayList<Card> cardList = new ArrayList<Card>();
	
	/**
	 * Constructor 
	 */
	public Deck() {
		generateDeck();
	}
	
	/**
	 * Generate New Deck
	 */
	private void generateDeck() {
		for (int i=1; i<5; i++)
			for (int j=1; j<14; j++)
				cardList.add(new Card(j,i));
	}
	
	/**
	 * Returns Boolean if empty
	 * @return Boolean
	 */
	public boolean isEmpty() {
		return cardList.isEmpty();
	}
	
	/**
	 * Return Deck Size
	 * @return Deck Size
	 */
	public int getSize() {
		return cardList.size();
	}
	
	/**
	 * Kills top Card
	 */
	public void killCard() {
		cardList.remove(0);
	}
	
	/**
	 * Draws a Card
	 * @return Drawn Card
	 */
	public Card drawCard() {
		return cardList.remove(0);
	}
	
	/**
	 * Shuffles the deck
	 */
	public void shuffle(){
		ArrayList<Card> shuffledDeck = new ArrayList<Card>();
		Random generator = new Random();
		while (!cardList.isEmpty()) {
			int r = generator.nextInt(cardList.size());
			shuffledDeck.add(cardList.remove(r));
		}
		this.cardList = shuffledDeck;
	}
}